from functools import lru_cache

with open('input.txt') as file:
    jolts = [int(line) for line in file.readlines()]
    jolts.sort()
    jolts = [0] + jolts + [jolts[-1] + 3]
    
    @lru_cache
    def arrangements(i):
        if i >= len(jolts):
            return 1
        x = jolts[i]
        result = arrangements(i + 1)

        if i + 2 < len(jolts) and jolts[i + 2] - x <= 3:
            result += arrangements(i + 2)

            if i + 3 < len(jolts) and jolts[i + 3] - x <= 3:
                result += arrangements(i + 3)

        return result

    print(arrangements(0))
        